package com.example.shortlink.dao.mapper;

import com.example.shortlink.dao.entity.LinkBrowserStats;
import com.mybatisflex.core.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;

public interface LinkBrowserStatsMapper extends BaseMapper<LinkBrowserStats> {

    @Insert("<script> " +
            "INSERT INTO " +
            "t_link_browser_stats " +
            "(full_short_url, " +
            "gid, " +
            "date, " +
            "cnt, " +
            "browser, " +
            "create_time, " +
            "update_time, " +
            "del_flag" +
            ") " +
            "VALUES" +
            "( " +
            "#{linkBrowserStats.fullShortUrl}, " +
            "#{linkBrowserStats.gid}, " +
            "#{linkBrowserStats.date}, " +
            "#{linkBrowserStats.cnt}, " +
            "#{linkBrowserStats.browser}, " +
            "NOW(), " +
            "NOW(), " +
            "0" +
            ") " +
            "ON DUPLICATE KEY UPDATE cnt = cnt +  #{linkBrowserStats.cnt} " +
            "</script>")
    void shortLinkBrowserState(@Param("linkBrowserStats") LinkBrowserStats linkBrowserStatsDO);
}